home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / examples / tcl / x03.tcl < prev    next >
Text File  |  1994-08-09  |  2KB  |  90 lines

  1. # $Id: x03.tcl,v 1.3 1994/08/09 08:23:23 mjl Exp $
  2. # $Log: x03.tcl,v $
  3. # Revision 1.3  1994/08/09  08:23:23  mjl
  4. # Changed to new tclMatrix notation.
  5. #
  6. # Revision 1.2  1994/07/19  22:36:49  mjl
  7. # Sped up some by eliminating half of the points.
  8. #
  9. # Revision 1.1  1994/06/30  18:49:35  mjl
  10. # Tcl demo programs, which fully reproduce their x??c counterpart.
  11. #
  12. #----------------------------------------------------------------------------
  13. # PLplot Tcl demo #3
  14. #
  15. # After sourcing, just type "3".
  16. #----------------------------------------------------------------------------
  17.  
  18. proc 3 {} {
  19.     set npts 180
  20.     set npts1 [expr $npts+1]
  21.  
  22.     matrix x0 f $npts1
  23.     matrix y0 f $npts1
  24.     matrix x f $npts1
  25.     matrix y f $npts1
  26.  
  27.     set dtr [expr 3.141592654 / 180.]
  28.     set dtheta [expr $dtr * 360. / $npts]
  29.  
  30.     for {set i 0} {$i <= $npts} {incr i} {
  31.     x0 $i = [expr cos($dtheta * $i)]
  32.     y0 $i = [expr sin($dtheta * $i)]
  33.     }
  34.  
  35. # Set up viewport and window, but do not draw box 
  36.  
  37.     plssub 1 1
  38.     plcol 1
  39.     plenv -1.3 1.3 -1.3 1.3 1 -2
  40.     for {set i 1} {$i <= 10} {incr i} {
  41.     for {set j 0} {$j <= $npts} {incr j} {
  42.         x $j = [expr 0.1 * $i * [x0 $j]]
  43.         y $j = [expr 0.1 * $i * [y0 $j]]
  44.     }
  45.  
  46. # Draw circles for polar grid
  47.  
  48.     plline $npts1 x $y
  49.     }
  50.  
  51.     plcol 2
  52.     for {set i 0} {$i <= 11} {incr i} {
  53.     set theta [expr 30.0 * $i]
  54.     set xg [expr cos($dtr * $theta)]
  55.     set yg [expr sin($dtr * $theta)]
  56.  
  57. # Draw radial spokes for polar grid
  58.  
  59.     pljoin 0.0 0.0 $xg $yg
  60.  
  61. # Write labels for angle
  62.  
  63.     if {$xg >= 0} {
  64.         set dx $xg
  65.         set dy $yg
  66.         set just -0.15
  67.     } else {
  68.         set dx [expr -$xg]
  69.         set dy [expr -$yg]
  70.         set just 1.15
  71.     }
  72.     plptex $xg $yg $dx $dy $just [expr round($theta)]
  73.     }
  74.  
  75. # Draw the graph 
  76.  
  77.     for {set i 0} {$i <= $npts} {incr i} {
  78.     set r [expr sin($dtheta * (5 * $i))]
  79.     x $i = [expr [x0 $i] * $r]
  80.     y $i = [expr [y0 $i] * $r]
  81.     }
  82.     plcol 3
  83.     plline $npts1 x $y
  84.  
  85.     plcol 4
  86.     plmtex "t" 2.0 0.5 0.5 "#frPLplot Example 3 - r(#gh)=sin 5#gh"
  87.  
  88.     pleop
  89. }
  90.